package com.imooc.sellspringcloud.server.mq.example;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;

/**
 * @author
 * @create 2019-08-05 23:39
 **/
@Component
public class OrderConfirmMq {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = "product-reduce-queue",
            durable = "false"),
            exchange = @Exchange(value = "product-reduce",
                    durable = "false",
                    type = "topic"),
            key = "productReduceKey"
    ))
    @RabbitHandler
    public void reduceCallback(Message message, Channel channel) {
        System.out.println("message: " + message.getPayload());
        System.out.println("headers: " + message.getHeaders().get("desc"));



        // stringRedisTemplate.opsForSet().add();
    }
}